local chuanwu = fk.CreateSkill {
  name = "rmt__chuanwu",
}

Fk:loadTranslationTable{
  ["rmt__chuanwu"] = "穿屋",
  [":rmt__chuanwu"] = "每回合限一次，你可以从虚空中使用一张军争模式不可用的牌。",

  ["#rmt__chuanwu"] = "穿屋：使用一张牌",

  ["$rmt__chuanwu1"] = "你还没有见过真正的恐惧。",
  ["$rmt__chuanwu2"] = "这些，你就感到害怕了吗？"
}

local U = require "packages.utility.utility"

chuanwu:addEffect("viewas", {
  pattern = ".",
  prompt = "#rmt__chuanwu",
  interaction = function (self, player)
    local all_names = player:getMark(chuanwu.name)
    return UI.CardNameBox {
      choices = player:getViewAsCardNames(chuanwu.name, all_names),
      all_choices = all_names,
    }
  end,
  card_filter = Util.FalseFunc,
  view_as = function(self, player, cards)
    if Fk.all_card_types[self.interaction.data] == nil then return end
    local card = Fk:cloneCard(self.interaction.data)
    card.skillName = chuanwu.name
    return card
  end,
  before_use = function(self, player, use)
    local room = player.room
    local copy = Fk.all_card_types[use.card.name]
    local card = room:printCard(copy.name, copy.suit, copy.number)
    room:moveCardTo(card, Card.Processing, nil, fk.ReasonUse)
    use.card:addSubcard(card.id)
  end,
  enabled_at_play = function(self, player)
    return player:usedSkillTimes(chuanwu.name, Player.HistoryTurn) == 0
  end,
  enabled_at_response = function(self, player, response)
    return not response and player:usedSkillTimes(chuanwu.name, Player.HistoryTurn) == 0 and
    #player:getViewAsCardNames(chuanwu.name, player:getMark(chuanwu.name)) > 0
  end,
})

chuanwu:addAcquireEffect(function (self, player, is_start)
  local all_names = {}
  local packNames = {"standard_cards", "maneuvering", "standard_ex_cards"}
  for _, name in ipairs(Fk.all_card_names) do
    local card = Fk:cloneCard(name)
    if not (card.package and table.contains(packNames, card.package.name)) then
      table.insertIfNeed(all_names, name)
    end
  end
  player.room:setPlayerMark(player, chuanwu.name, all_names)
end)

return chuanwu
